(function(){
    var locationarr=['price','saveMoney','domesticDiscount','lowprice','saveMoney',
    'coupon','price','#','collectProduct','price','shopNav','brand']
    var arrlist=[]
    $.ajax({
        url:"http://chst.vip:1234/api/getindexmenu",
    }).then(res=>{
        // res=res.result
        // res.forEach((item,index)=>{
        //     let arr={}
        //     arr.img=`./assets/image/${index+1}.png`
        //     arr.name=item.name
        //     arr.indexmenuId=item.indexmenuId
        //     arrlist.push(arr)})
        arrlist=res.result.map((item,index)=>{
            return {
                img:`./assets/image/${index+1}.png`,
                name:item.name,
                indexmenuId:item.indexmenuId
            }
        })

    // 
    let html=arrlist.reduce((value,item,index)=>{
        return value+`
                <div class="nav-icon" indexmenuid=${item.indexmenuId}>
                    <a href=${index!==7 ? './pages/'+locationarr[index]+'.html': locationarr[index]}><img src="${item.img}" alt=""></a>
                     <p>${item.name}</p>
                </div>
        `
    },"")
    $('nav .container').html(html)

    const HEIGHT=$('nav').height()
    // $('nav').height("5.49rem")

    let flag=false
    $(".nav-icon").eq(7).click(()=>{
        if(flag){
            $('nav').animate({height:HEIGHT},300)
        }else{
            $('nav').animate({height:"5.49rem"},300)
        }
        flag=!flag
    })
    })

    $.ajax({
        url:"http://chst.vip:1234/api/getmoneyctrl"
    }).then(res=>{
        let html=res.result.reduce((value,item,index)=>{
            return value+`
            <li productId=${item.productId}>
            <a href="../pages/indexXiang.html?productid=${item.productId}">
                ${item.productImg2}
                <div class="info-fr">
                    <h4>${item.productName} <span>${item.productPinkage}</span></h4>
                    <span class="fl">${item.productFrom}|${item.productTime}</span>
                    <em class="fr">
                        <i class="iconfont">&#xe602;</i>
                        <span>${item.productComCount}</span>
                    </em>
                 </div>
            </a>
        </li>
            `
        },"")
        $(".info").html(html)
    })
})()